package cn.edu.zjgsu.ito.service;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class AdminScoHistoryService {
	
	/**
	 * 学生历史成绩页面
	 * 杨昆鹏
	 * */

	public List<Record> scoHistory(){
			
		//termValue,courseName,passportNo,grade,gradeStatus,     sNo,lastName,firstName,
		
		List<Record> retgra = new ArrayList<Record>();//前台
		
		List<Record> records = Db.find("select * from student_grade");//基本信息
		
		System.out.println("---1---");
		
		for(int i = 0 ; i < records.size() ; i++){
			String passportNo = records.get(i).getStr("passportNo");
			Record names = Db.findFirst("select * from student_info where passportNo=?",passportNo);//学号姓名
			
			System.out.println(names.getStr("sNo"));
			System.out.println("---2---");
			System.out.println("---2---");
			String termValue = records.get(i).getStr("termValue");
			String courseName = records.get(i).getStr("courseName");
			System.out.println("---2---");
			String grade = records.get(i).getStr("grade");
			System.out.println("---2---");
			
//			String gradeStatus = records.get(i).getStr("gradeStatus");
			
			System.out.println("---2---");
			String sNo = names.getStr("sNo");
			String lastName = names.getStr("lastName");
			String firstName = names.getStr("firstName");
			System.out.println("---2---");
			System.out.println(passportNo+"=="+sNo+"=="+"=="+termValue+"=="+courseName+"=="
					+grade+"=="+"=="+lastName+"=="+firstName);
			
			Record stu = new Record().set("termValue",termValue).set("passportNo",passportNo)
					.set("courseName",courseName).set("grade",grade)
//					.set("gradeStatus",gradeStatus)
					.set("sNo",sNo)
					.set("lastName",lastName).set("firstName",firstName);
			System.out.println("---4---");
			retgra.add(stu);
			System.out.println("---5---");
			System.out.println(records.get(i).getStr("passportNo"));
		}
		System.out.println("---6---");
		return retgra;	
	}
}
